<template>
	<view class="bgcolor">
		<header-top :messageInfo="{typeFlag:true,message:'设置'}"></header-top>
		<view class="conts margin_top">
			<view v-for="(item,index) in amend" :key="index" class="flexbetween"
				style="background-color: #fff;padding:30rpx 40rpx;box-sizing: border-box;"
				@click="gotoChange(index)">
				{{item}}
				<u-icon name='arrow-right'></u-icon>
			</view>
			<view class="flexbetween"
				style="background-color: #fff;padding:30rpx 40rpx;box-sizing: border-box;">
				<view class="">版本号</view>
				<view class="">{{version}}</view>
			</view>
		</view>
		<view class="conts flexcenter" @click="show=true,hao=1"
			style="background-color: #fff;padding:30rpx 40rpx;box-sizing: border-box;margin: 20rpx 0;">
			<view>切换账号</view>
		</view>
		<!-- <view class="mainpadding">
			<view class="buttonStyle flexcenter" @click="show=true,hao=1">切换账号</view>
		</view> -->
		<view class="conts flexcenter" @click="show=true,hao=0"
			style="background-color: #fff;padding:30rpx 40rpx;box-sizing: border-box;margin: 20rpx 0;">
			<view>退出登录</view>
		</view>
		

		<u-modal title='提示'  :content='hao?"是否切换账号":"是否退出登录"' :show="show" @confirm="confirm" ref="uModal"
			:asyncClose="true" style='text-align: center;' :showCancelButton='true' @cancel='cancel'></u-modal>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				amend: ['修改登录手机号', '修改登录密码'],
				show: false,
				hao: 0,
				version:"",
			}
		},
		onLoad() {
			let that = this
			// #ifdef APP-PLUS
			plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
				console.log(widgetInfo,"888");
				that.version = widgetInfo.version
			});  
			// #endif
		},
		methods: {
			showModal() {
				this.show = true;
			},
			confirm() {
				this.show = false;
				// 0退出登录1切换账号
				if(this.hao==0){
					// httpRequest.request('appapi/staff/login/logout', 'POST', {
					// }).then(res => {})
					// httpRequest.toast("退出登录成功");
					// setTimeout(() => {
					// 	// 将存储的数据改为空达到退出登录的效果
					// 		uni.setStorageSync('token',"");
					// 		uni.setStorageSync('user_id',"");
					// 		uni.reLaunch({
					// 			url:"/pages/thelogin/thelogin"
					// 		})
					// }, 1000)
					httpRequest.toast("退出登录成功");
					setTimeout(() => {
						// 将存储的数据改为空达到退出登录的效果
							uni.setStorageSync('token',"");
							uni.setStorageSync('user_id',"");
							uni.reLaunch({
								url:"/pages/thelogin/thelogin"
							})
					}, 1000)
				}else{
					uni.navigateTo({
						url:'/pages/thelogin/thelogin?msg=0'
					})
				}
			},
			cancel() {
				this.show = false
			},
			//去跳转到修该页面
			gotoChange(i){
				console.log(i);
				if(i==0){
					uni.navigateTo({
						url:'./changePhone'
					})
				}
				if(i==1){
					uni.navigateTo({
						url:'./changePass'
					})
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	/deep/.u-modal__content__text{
		text-align: center;
	}
</style>
